﻿using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Collections.Generic;

namespace WcfService1
{  
    [ServiceContract(Namespace = "JsonpAjaxService")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ArticuloService
    {
        [WebGet(ResponseFormat = WebMessageFormat.Json)]
        public List<Articulo> Articulos()
        {
            var articulos = new List<Articulo> { 
                new Articulo { Id=1, Nombre= "Samsung Galaxy Ace", Precio=899, Cantidad=10, UrlImagen="1.jpg" },
                new Articulo { Id=2, Nombre= "Polos 100% Algodon", Precio=60, Cantidad=50, UrlImagen="2.jpg" },             
            };

            return articulos;
        }
    }

    [DataContract]
    public class Articulo
    {
        int id;
        string nombre;
        double precio;
        int cantidad;
        string urlImagen;

        [DataMember]
        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        [DataMember]
        public string Nombre
        {
            get { return nombre; }
            set { nombre = value; }
        }

        [DataMember]
        public double Precio
        {
            get { return precio; }
            set { precio = value; }
        }

        [DataMember]
        public int Cantidad
        {
            get { return cantidad; }
            set { cantidad = value; }
        }

        [DataMember]
        public string UrlImagen
        {
            get { return urlImagen; }
            set { urlImagen = value; }
        }
    }

}
